﻿using System;
using SimpleInjector;
using Sustainalytics.Synchronization.Interface;


namespace Sustainalytics.Governance.Synchronization
{
    public class GovernanceSyncStep : ISyncStep
    {
        protected Container SimpleInjectorContainer;

        public SyncStepOrder ExecutionOrder => SyncStepOrder.SyncGovernance;


        public GovernanceSyncStep()
        {
        }

        public SyncContext Start(SyncContext syncContext)
        {
            // check for task cancellation
            syncContext.Token.ThrowIfCancellationRequested();


            SimpleInjectorContainer = SimpleInjectorConfig.Register(new SyncContextLogger(syncContext), syncContext.GAConnectionStrings);

            var governanceSync = SimpleInjectorContainer.GetInstance<GovernanceSync>();

            return governanceSync.Start(syncContext);

        }
     
    }
}
